def month_before(a_time)
    a_time - 28 * 24 * 60 * 60
end

def header(date)
    date.strftime("Changes since %Y-%m-%d:")
end

def subsystem_line(subsystem_name, count_change)
    "#{subsystem_name.rjust(14)} #{stars(count_change)}(#{count_change})"
end

def stars(number_of_changes)
    "*"*((number_of_changes/5.0).round)
end

def number_of_changes(subfolder_name, start_date)
    extract_number_of_changes(get_svn_log(subfolder_name, start_date))
end

def extract_number_of_changes(text)
    lines = text.split("\n")
    dashed_lines = lines.find_all {|line| line.include?("----")}
    dashed_lines.length-1
end

def get_svn_log(subsystem, start_date)
    timespan = "--revision 'HEAD:{#{start_date}}'"
    path = "https://sydneyuni.googlecode.com/svn"

    `svn log #{timespan} #{path}`
end

